package com.uzai.common.enums;

/**
 * 订单来源
 * @author liuqi
 * @date 2021/8/27 17:19
 * @param
 * @return null
 */
public enum OrderSourceEnum {

    /**
     * PC个人微信
     */
    DT_PC_WECHAT(0,"private_wechat", "PC个人微信"),

    /**
     * 安卓手机个人微信
     */
    DT_ANDROID_WECHAT(1,"private_wechat","安卓手机个人微信"),

    /**
     * PC企业微信
     */
    DT_WORK_WECHAT(2,"work_wechat","PC企业微信"),

    /**
     * Ipad协议个人微信
     */
    DT_IPAD_WECHAT(3,"private_wechat","Ipad协议个人微信"),

    /**
     * CMS
     */
    CMS(4,"cms","CMS"),

    /**
     * 小程序
     */
    MINI_PRO(5,"mini_pro","小程序"),

    /**
     * 公众号
     */
    WX_PUB(6,"wx_pub","公众号"),

    /**
     * 单品推荐中间页
     */
    MIDDLE_PAGE(7,"middle_page","单品推荐中间页"),

    /**
     * 微信朋友圈
     */
    WECHAT_PYQ(8,"wechat_pyq","微信朋友圈"),

    /**
     * 社群发单
     */
    WECHAT_FD(9,"wechat_fd","社群发单"),

    /**
     * APP
     */
    APP(10,"app","app"),

    /**
     * APP
     */
    APP_MIDDLE_PAGE(11,"app_middle_page","app单品推荐中间页"),

    ;

    private Integer id;
    private String value;
    private String desc;

    OrderSourceEnum(Integer id, String value, String desc) {
        this.id = id;
        this.value = value;
        this.desc = desc;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static OrderSourceEnum getById(Integer id) {
        if (id == null) {
            return null;
        }
        for (OrderSourceEnum type: OrderSourceEnum.values()) {
            if (type.getId().intValue() == id) {
                return type;
            }
        }
        return null;
    }

    public static OrderSourceEnum getByDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (OrderSourceEnum type: OrderSourceEnum.values()) {
            if (type.getDesc().equals(desc)) {
                return type;
            }
        }
        return null;
    }
}
